/*
 * Copyright (c) 2025 Evlers
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * Change Logs:
 * Date         Author      Notes
 * 2024-12-26   Evlers      first implementation
 */

#ifndef __CONFIG_CONVERT_H__
#define __CONFIG_CONVERT_H__

#include "os_header.h"

/* RT-Thread to ESP-Hosted configuration */

/* Transport interface */
#ifdef ESP_HOSTED_SPI_HOST_INTERFACE
#define CONFIG_ESP_SPI_HOST_INTERFACE 1
#endif
#ifdef ESP_HOSTED_SDIO_HOST_INTERFACE
#define CONFIG_ESP_SDIO_HOST_INTERFACE 1
#endif

/* SPI mode */
#if defined(ESP_HOSTED_SPI_MODE_0)
#define ESP_HOSTED_SPI_MODE     RT_SPI_MODE_0
#elif defined(ESP_HOSTED_SPI_MODE_1)
#define ESP_HOSTED_SPI_MODE     RT_SPI_MODE_1
#elif defined(ESP_HOSTED_SPI_MODE_2)
#define ESP_HOSTED_SPI_MODE     RT_SPI_MODE_2
#elif defined(ESP_HOSTED_SPI_MODE_3)
#define ESP_HOSTED_SPI_MODE     RT_SPI_MODE_3
#else
#define ESP_HOSTED_SPI_MODE     RT_SPI_MODE_3
#warning "spi is configured as the default mode 3."
#endif

/* Raw Throughput Testing */
#ifdef ESP_HOSTED_PKT_STATS
#define CONFIG_ESP_PKT_STATS
#endif

/* Slave chipset */
#ifdef ESP_HOSTED_SLAVE_CHIPSET_ESP32
#define CONFIG_SLAVE_CHIPSET_ESP32 1
#endif
#ifdef ESP_HOSTED_SLAVE_CHIPSET_ESP32C2
#define CONFIG_SLAVE_CHIPSET_ESP32C2 1
#endif
#ifdef ESP_HOSTED_SLAVE_CHIPSET_ESP32C3
#define CONFIG_SLAVE_CHIPSET_ESP32C3 1
#endif
#ifdef ESP_HOSTED_SLAVE_CHIPSET_ESP32C6
#define CONFIG_SLAVE_CHIPSET_ESP32C6 1
#endif
#ifdef ESP_HOSTED_SLAVE_CHIPSET_ESP32S2
#define CONFIG_SLAVE_CHIPSET_ESP32S2 1
#endif
#ifdef ESP_HOSTED_SLAVE_CHIPSET_ESP32S3
#define CONFIG_SLAVE_CHIPSET_ESP32S3 1
#endif
#ifdef ESP_HOSTED_SLAVE_CHIPSET_ESP32C5
#define CONFIG_SLAVE_CHIPSET_ESP32C5 1
#endif

/* WiFi Configuration */
#define CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM        ESP_WIFI_STATIC_RX_BUFFER_NUM
#define CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM       ESP_WIFI_DYNAMIC_RX_BUFFER_NUM
#define CONFIG_ESP_WIFI_TX_BUFFER_TYPE              ESP_WIFI_TX_BUFFER_TYPE
#define CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM       ESP_WIFI_DYNAMIC_TX_BUFFER_NUM

#ifdef ESP_WIFI_AMPDU_TX_ENABLED
#define CONFIG_ESP_WIFI_AMPDU_TX_ENABLED    1
#else
#define CONFIG_ESP_WIFI_AMPDU_TX_ENABLED    0
#endif

#define CONFIG_ESP_WIFI_TX_BA_WIN                   ESP_WIFI_TX_BA_WIN

#ifdef ESP_WIFI_AMPDU_RX_ENABLED
#define CONFIG_ESP_WIFI_AMPDU_RX_ENABLED    1
#else
#define CONFIG_ESP_WIFI_AMPDU_RX_ENABLED    0
#endif

#define CONFIG_ESP_WIFI_RX_BA_WIN                   ESP_WIFI_RX_BA_WIN
#define CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN       ESP_WIFI_SOFTAP_BEACON_MAX_LEN
#define CONFIG_ESP_WIFI_MGMT_SBUF_NUM               ESP_WIFI_MGMT_SBUF_NUM

#ifdef ESP_WIFI_STA_DISCONNECTED_PM_ENABLE
#define CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE  1
#else
#define CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE  0
#endif

#define CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM      ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM

/* BT Configuration */
#ifdef ESP_HOSTED_BT_ENABLED
#define CONFIG_ESP_ENABLE_BT 1
#ifdef ESP_HOSTED_BT_USING_NIMBLE_STACK
#define CONFIG_BT_NIMBLE_ENABLED 1
#endif
#endif

/* RPC Configuration */
#define CONFIG_ESP_MAX_SIMULTANEOUS_SYNC_RPC_REQUESTS ESP_HOSTED_MAX_SIMULTANEOUS_SYNC_RPC_REQUESTS
#define CONFIG_ESP_MAX_SIMULTANEOUS_ASYNC_RPC_REQUESTS ESP_HOSTED_MAX_SIMULTANEOUS_ASYNC_RPC_REQUESTS

#endif /* __CONFIG_CONVERT_H__ */
